<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<script>
description("Verify the use of IDBVersionChangeEventInit");

evalAndLog("event = new IDBVersionChangeEvent('default')");
shouldBeTrue("event instanceof IDBVersionChangeEvent");
shouldBeEqualToString("event.type", "default");
shouldBe("event.oldVersion", "0");
shouldBe("event.newVersion", "null");
shouldBe("event.dataLoss", '"none"');

debug("");
evalAndLog("initEvent = {oldVersion: 123, newVersion: 456}");
evalAndLog("event = new IDBVersionChangeEvent('foo', initEvent)");
shouldBeTrue("event instanceof IDBVersionChangeEvent");
shouldBeEqualToString("event.type", "foo");
shouldBe("event.oldVersion", "initEvent.oldVersion");
shouldBe("event.newVersion", "initEvent.newVersion");
shouldBe("event.dataLoss", '"none"');

debug("");
evalAndLog("initEvent = {oldVersion: 124, newVersion: 457, dataLoss: 'total'}");
evalAndLog("event = new IDBVersionChangeEvent('foo2', initEvent)");
shouldBeTrue("event instanceof IDBVersionChangeEvent");
shouldBeEqualToString("event.type", "foo2");
shouldBe("event.oldVersion", "initEvent.oldVersion");
shouldBe("event.newVersion", "initEvent.newVersion");
shouldBe("event.dataLoss", "initEvent.dataLoss");

debug("");
evalAndLog("initEvent = {oldVersion: 'legacy', newVersion: null}");
evalAndLog("event = new IDBVersionChangeEvent('bar', initEvent)");
shouldBeTrue("event instanceof IDBVersionChangeEvent");
shouldBeEqualToString("event.type", "bar");
// We pull strings out of legacy databases, but don't let them be created
shouldBe("event.oldVersion", "0");
shouldBeNull("event.newVersion");
shouldBe("event.dataLoss", '"none"');

</script>
